#include <iostream>
#include "complex.h"
using namespace std;

inline complex& complex::operator+=(const complex &r)
{
    return _doapl(this, r);
}

inline complex& _doapl(complex *ths, const complex& r)
{
    ths->re += r.re;
    ths->im += r.im;
    return *ths;
}

inline complex operator + (const complex& left, const complex& right)
{
    return complex(left.real() + right.real(), left.imag() + right.imag());
}

inline double real(const complex& num)
{
    return num.real();
}

inline double imag(const complex& num)
{
    return num.imag();
}

inline complex operator + (const complex& left, const double right)
{
    return complex(left.real() + right, left.imag());
}

inline complex operator + (const double left, const complex& right)
{
    return complex(left + right.real(),  right.imag());
}

inline ostream& operator << (ostream& os, const complex& num)
{
    cout << "[" << num.real() << "," << num.imag() << "]" << endl;
}

int main()
{
    complex num(2, 3);
    cout << num;
    return 0;
}